package com.richapp.launcher.utils;

import android.text.TextUtils;

import com.richapp.launcher.database.system.mode.DeviceModel;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wangwei on 2017/4/10.
 */

public class BizUtils {

    public static String getAirQuaLevel(String paramString) {
        if (!TextUtils.isEmpty(paramString)) {
            if (paramString.equals("7")) {
                return "非常差";
            } else if (paramString.equals("6")) {
                return "很差";
            } else if (paramString.equals("5")) {
                return "差";
            } else if (paramString.equals("4")) {
                return "中";
            } else if (paramString.equals("3")) {
                return "良";
            } else if (paramString.equals("2")) {
                return "优";
            } else if (paramString.equals("1")) {
                return "最优";
            }
        }

        return "";
    }


    public static String getPM25Level(String paramString) {
        String str = "";
        if (!TextUtils.isEmpty(paramString)) {

            if (paramString.matches("[0-9]+")) {
                int i = Integer.parseInt(paramString);
                if (i >= 1 && i <= 35) {
                    str = "优";
                }
                if ((i > 35) && (i < 75)) {
                    str = "良";
                } else if ((i >= 75) && (i <= 115)) {
                    str = "轻度污染";
                } else if ((i > 115) && (i <= 150)) {
                    str = "中度污染";
                } else if ((i > 150) && (i <= 250)) {
                    str = "重度污染";
                } else if (i > 250) {
                    str = "严重污染";
                }
            }
        }
        return str;
    }

    public static String getSunLightLevel(String paramString) {
        if (!TextUtils.isEmpty(paramString)) {
            if (paramString != null && (paramString.matches("[0-9]+"))) {
                int i = Integer.parseInt(paramString);
                if (i == 0) {
                    return "最暗";
                } else if ((i >= 1) && (i <= 3)) {
                    return "很暗";
                } else if ((i >= 4) && (i <= 8)) {
                    return "暗";
                } else if ((i >= 9) && (i <= 20)) {
                    return "微亮";
                } else if ((i >= 21) && (i <= 40)) {
                    return "亮";
                } else if ((i >= 41) && (i <= 100)) {
                    return "明亮";
                } else if (i >= 101 && i <= 2999) {
                    return "很亮";
                } else if (i > 2999) {
                    return "最亮";
                }
                return "最亮";
            }
        }
        return "";
    }

    public static List<List<DeviceModel>> parseList(List<DeviceModel> deviceModels) {

        List<List<DeviceModel>> deviceModelList = new ArrayList<List<DeviceModel>>();
        List<DeviceModel> list = new ArrayList<DeviceModel>();
        for (int i = 1; i <=deviceModels.size(); i++) {
            DeviceModel model = deviceModels.get(i-1);
            list.add(model);
            if (i != 0 && list.size() % 4 == 0) {
                deviceModelList.add(list);
                list = new ArrayList<>();
            }


            if (deviceModels.size() == i && list.size() > 0) {
                deviceModelList.add(list);
            }
        }
        return deviceModelList;
    }
}
